package com.zzsxy.Lambda;

import java.util.Random;

public class LanbdaText01 {
    /*
    尝试匿名内部类，Lambda 两种方式，处理方法的形参是接口（或者抽象类，此处以接口演示）
     */

    public static void main(String[] args) {
        RandomNum(new RanNumInter() {
            @Override
            public int RanNum() {
                System.out.print("匿名内部类输出:");
                return new Random().nextInt(100)+1;
            }
        });

        System.out.print("Lambda中输出：");
        RandomNum(()-> new Random().nextInt(100)+1);


    }

    public static void RandomNum(RanNumInter ran){
        int result = ran.RanNum();
        System.out.println(result);
    }

}

interface RanNumInter{
    public int RanNum();
}

